Platform Explorer / Nuxeo Platform 2021.57

Extension point defaultRendition

Documentation

Defines the default rendition of a given document. Contributions are of the form:

    <defaultRendition reason="download">
        <script language="JavaScript">
            function run() {
              if (CurrentUser.getName() != "bob") {
                return null;
              }
              if (!CurrentUser.getGroups().contains("members")) {
                return 'aRenditionName`;
              }
              if (Document.getPropertyValue("dc:format") != "pdf") {
                return 'pdfRendition';
              }
              return 'aDefaultRendition';
          </script>
    </defaultRendition>

The language can be any JVM scripting language, the default is "JavaScript".

The reason is optional: - "download" will be used in the context of bulk download. - "publish" will be used to publish the default rendition.

The script must define a "run()" function that returns a string which is the name of the rendition to be used. The method will get called with the following global context (some values may be null): Document (DocumentModel) CurrentUser (NuxeoPrincipal), Infos (Map).

Contribution Descriptors

  • Class: org.nuxeo.ecm.platform.rendition.service.DefaultRenditionDescriptor

Existing Contributions

Contributions are presented in the same order as the registration order on this extension point. This order is displayed before the contribution name, in brackets.

  • nuxeo-platform-rendition-core-2021.57.3.jar /OSGI-INF/rendition-download-contrib.xml
    <extension point="defaultRendition" target="org.nuxeo.ecm.platform.rendition.service.RenditionService">
        <defaultRendition reason="download">
          <script language="JavaScript">
            function run() {
              if (Document.getFacets().contains("Collection")) {
                return 'containerDefaultRendition';
              } else if (Document.getFacets().contains("Folderish")) {
                return 'containerDefaultRendition';
              } else if (Document.hasSchema("file")) {
                return 'mainBlob';
              } else if (Document.getType() == 'Note') {
                return 'pdf';
              } else {
                return 'xmlExport';
              }
            }
          </script>
        </defaultRendition>
      </extension>
  • nuxeo-platform-rendition-core-2021.57.3.jar /OSGI-INF/rendition-contrib.xml
    <extension point="defaultRendition" target="org.nuxeo.ecm.platform.rendition.service.RenditionService">
        <defaultRendition>
          <script language="JavaScript">
            function run() {
              return 'xmlExport';
            }
          </script>
        </defaultRendition>
      </extension>
  • nuxeo-platform-rendition-core-2021.57.3.jar /OSGI-INF/rendition-publish-contrib.xml
    <extension point="defaultRendition" target="org.nuxeo.ecm.platform.rendition.service.RenditionService">
        <defaultRendition reason="publish">
          <script language="JavaScript">
            function run() {
              if (Document.getType() == "File" || Document.getType() == "Note") {
                return 'pdf';
              } else if (Document.hasSchema("file")) {
                return 'mainBlob';
              }
              return null;
            }
          </script>
        </defaultRendition>
      </extension>